<template>
  <div>
    <div class="search-nav">
      <div :class="{ active: flag1 == 0 }" @click="synthesis">综合</div>
      <div class="price" @click="goodssort">
        <span :class="{ active: flag1 == 1 }">价格</span>
        <span class="price-icon">
          <van-icon
            name="arrow-up"
            class="icon-price"
            :class="{ active: flag == 1 }"
          />
          <van-icon
            name="arrow-down"
            color=""
            class="icon-price"
            :class="{ active: flag == 2 }"
          />
        </span>
      </div>
      <div :class="{ active: flag1 == 2 }" @click="sort">分类</div>
    </div>
  </div>
</template>

<script>
import { goodsList } from "@/api/home/HomeCategory";
export default {
  data() {
    return {
      flag: 0,
      flag1: "",
      goodlist: [],
    };
  },
  methods: {
    async getdata() {
      let id = this.$route.query.id;
      let res = await goodsList({
        isHot: id == 0 ? "" : "1",
        isNew: id == 0 ? "1" : "",
        order: this.flag == 1 ? "asc" : "desc",
      });
      this.goodlist = res.data;
      this.$store.commit("GOODLIST", res.data);
    },
    goodssort() {
      this.flag1 = 1;
      this.flag =this.flag== 1 ? "2" : "1";
      this.getdata();
    },
    synthesis() {
      this.flag1 = 0;
      this.flag = 0;
    },
    sort() {
      this.flag1 = 2;
      this.flag = 0;
    },
  },
};
</script>

<style scoped lang='scss'>
.search-nav {
  width: 100%;
  height: 40px;
  display: flex;
  justify-content: space-around;
  font-size: 28px;
  color: #212121;
  letter-spacing: 0;
  font-weight: 400;
  .price {
    display: flex;
    height: 100%;
    .price-icon {
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      padding-bottom: 17px;
      .icon-price {
        width: 13.3px;
        height: 6.6px;
      }
    }
  }
  .active {
    color: #cea62a;
  }
}
</style>